/* Copyright (c) 2004-2024 peigen.info. All rights reserved. */

package info.peigen.hotpot.business.product.manage.convertor;

import cn.hutool.core.bean.BeanUtil;
import info.peigen.hotpot.business.product.core.domain.ProductBrand;
import info.peigen.hotpot.business.product.core.repository.entity.ProductBrandEntity;
import info.peigen.hotpot.business.product.manage.form.ProductBrandManageCreateForm;
import info.peigen.hotpot.business.product.manage.form.ProductBrandManageEditForm;
import info.peigen.hotpot.business.product.manage.form.ProductBrandManageSearchForm;
import info.peigen.hotpot.business.product.manage.info.ProductBrandManageInfo;
import info.peigen.hotpot.common.core.util.IdUtil;
import lombok.extern.slf4j.Slf4j;

/**
 * <b>(ProductBrandManageConvertor)</b>
 * 管理后台领域对象 "商品品牌" 转换器
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2024-05-02
 */
@SuppressWarnings("unused")
@Slf4j
public class ProductBrandManageConvertor {
    // ConvertToEntity
    public static ProductBrandEntity convertToEntity(ProductBrand domain) {
        return BeanUtil.copyProperties(domain, ProductBrandEntity.class);
    }

    public static ProductBrandEntity convertToEntity(ProductBrandManageInfo info) {
        return BeanUtil.copyProperties(info, ProductBrandEntity.class);
    }

    public static ProductBrandEntity convertToEntity(ProductBrandManageSearchForm form) {
        return BeanUtil.copyProperties(form, ProductBrandEntity.class);
    }

    public static ProductBrandEntity convertToEntity(ProductBrandManageCreateForm form) {
        if (form.getBrandId() == null) {
            form.setBrandId(IdUtil.id());
        }
        return BeanUtil.copyProperties(form, ProductBrandEntity.class);
    }

    public static ProductBrandEntity convertToEntity(ProductBrandManageEditForm form) {
        return BeanUtil.copyProperties(form, ProductBrandEntity.class);
    }

    // ConvertToDomain
    public static ProductBrand convertToDomain(ProductBrandEntity entity) {
        return BeanUtil.copyProperties(entity, ProductBrand.class);
    }

    public static ProductBrand convertToDomain(ProductBrandManageInfo info) {
        return BeanUtil.copyProperties(info, ProductBrand.class);
    }

    public static ProductBrand convertToDomain(ProductBrandManageSearchForm form) {
        return BeanUtil.copyProperties(form, ProductBrand.class);
    }

    public static ProductBrand convertToDomain(ProductBrandManageCreateForm form) {
        if (form.getBrandId() == null) {
            form.setBrandId(IdUtil.id());
        }
        return BeanUtil.copyProperties(form, ProductBrand.class);
    }

    public static ProductBrand convertToDomain(ProductBrandManageEditForm form) {
        return BeanUtil.copyProperties(form, ProductBrand.class);
    }

    // convertToInfo
    public static ProductBrandManageInfo convertToInfo(ProductBrand domain) {
        return BeanUtil.copyProperties(domain, ProductBrandManageInfo.class);
    }

    public static ProductBrandManageInfo convertToInfo(ProductBrandEntity entity) {
        return BeanUtil.copyProperties(entity, ProductBrandManageInfo.class);
    }

    public static ProductBrandManageInfo convertToInfo(ProductBrandManageSearchForm form) {
        return BeanUtil.copyProperties(form, ProductBrandManageInfo.class);
    }

    public static ProductBrandManageInfo convertToInfo(ProductBrandManageCreateForm form) {
        if (form.getBrandId() == null) {
            form.setBrandId(IdUtil.id());
        }
        return BeanUtil.copyProperties(form, ProductBrandManageInfo.class);
    }

    public static ProductBrandManageInfo convertToInfo(ProductBrandManageEditForm form) {
        return BeanUtil.copyProperties(form, ProductBrandManageInfo.class);
    }
}